package com.molichuxing.services.infrastructure.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.molichuxing.framework.dto.Paged;
import com.molichuxing.framework.utils.ObjectCastUtil;
import com.molichuxing.services.infrastructure.bean.PyThreeverifyNotifyLogBean;
import com.molichuxing.services.infrastructure.convertor.Convert;
import com.molichuxing.services.infrastructure.dao.PyThreeverifyNotifyLogMapper;
import com.molichuxing.services.infrastructure.dto.request.create.PyThreeverifyNotifyLogCreateDto;
import com.molichuxing.services.infrastructure.dto.response.PyThreeverifyNotifyLogDto;
import com.molichuxing.services.infrastructure.service.PyThreeverifyNotifyLogService;
/**
 * 
 * @author liyg
 * 鹏元三要素接口服务
 * 2019-09-23
 *
 */
@Service("pyThreeverifyNotifyLogService")
public class PyThreeverifyNotifyLogServiceImpl implements PyThreeverifyNotifyLogService{

	@Autowired
	private PyThreeverifyNotifyLogMapper pyThreeverifyNotifyLogMapper;
	
	/**
	 * 保存
	 * @param createDto
	 * @return
	 */
	@Override
	public Integer create(PyThreeverifyNotifyLogCreateDto createDto) {
		PyThreeverifyNotifyLogBean bean=new PyThreeverifyNotifyLogBean();
		BeanUtils.copyProperties(createDto, bean);
		pyThreeverifyNotifyLogMapper.create(bean);
		return bean.getId();
	}
	
	/**
	 * 获取鹏元三要素验证日志
	 * 
	 * @param map
	 *            参数
	 *key:idNumber
	 *            String 身份证号 非必填
	 *key:realName
	 *            String 用户真实姓名 非必填
	 *key:userPhone
	 *            String 用户手机号 非必填
	 *key:startTime
	 *            String 请求开始时间 非必填
	 *key:endTime
	 *            String 请求结束时间 非必填
	 *key:pageNum
	 *            Integer 当前页
	 *key:pageSize
	 *            Integer 每页显示条数
	 * @return
	 */
	@Override
	public Paged<PyThreeverifyNotifyLogDto> getPyThreeverifyNotifyLogList(Map<String, Object> map) {
		// 查询总条数
		long total = pyThreeverifyNotifyLogMapper.getPyThreeverifyNotifyLogListCount(map);
		if(total <= 0) {
			return null;
		}
		
		/*分页查询集合*/ 
		Integer pageNum = ObjectCastUtil.castInteger(map.get("pageNum"));
		Integer pageSize = ObjectCastUtil.castInteger(map.get("pageSize"));       
		List<PyThreeverifyNotifyLogBean>  list =  pyThreeverifyNotifyLogMapper.getPyThreeverifyNotifyLogList(map,pageNum,pageSize);
		List<PyThreeverifyNotifyLogDto> dtoList = Convert.PyThreeverifyNotifyLogDto(list);
		Paged<PyThreeverifyNotifyLogDto> paged = new Paged<>(dtoList, total,pageSize);
		return paged;		
	}
}
